//表格生成函数
function Table_generation(aInput, index) {
  console.log(index);
  var oDiv = document.querySelector("div");
  var tb = document.createElement("table");
  oDiv.appendChild(tb); //写入table
  console.log("创建table");
  var Tr = document.createElement("tr");
  var table_flag = document.querySelectorAll("table");
  table_flag[index].appendChild(Tr); //写入tr
  console.log("创建tr");
  var tr_flag = document.querySelectorAll("tr");
  for (var i = 0; i < 3; i++) {
    //写入td
    tr_flag[index].appendChild(document.createElement("td"));
    console.log("创建td");
  }
  var aTd = tr_flag[index].querySelectorAll("td"); //选取td并写入样式
  for (var i = 0; i < 3; i++) {
    aTd[i].style.borderWidth = "thin";
    aTd[i].style.borderStyle = "solid";
    aTd[i].style.borderColor = "black";
    aTd[i].style.width = "100px";
    aTd[i].style.height = "20px";
    aTd[i].style.fontSize = "16px";
    aTd[i].innerText = aInput[i].value; //传值
  }
  tr_flag[index].appendChild(document.createElement("button")); //选取button并写入样式
  var btn_flag = tr_flag[index].querySelector("button");
  btn_flag.style.width = "50px";
  btn_flag.style.height = "25px";
  btn_flag.innerText = "删除";
  btn_flag.onclick = function () {
    table_flag[index].remove();
    count--;
  };
}
// Table_generation();
var aInput = document.querySelectorAll("input");
var btn = document.querySelector("button");
var count = 0;
btn.onclick = function () {
  Table_generation(aInput, count);
  count++;
};
// var aTr = document.querySelectorAll("tr");
// for (var i = 0; i < aTr.length; i++) {
//   var aBtn = aTr[i].querySelectorAll("button");
// }
// aBtn[aBtn.length - 1].onclick = function () {
//   var num;
// };
